#pragma once
#include "../im.h"
#include "IMUser.h"

// class IMUser;
// typedef std::shared_ptr<IMUser> IMUserPtr;
class IMUserManager
{
private:
    static IMUserManager *instance_;
    // 用户 uid -> user 不管用户有没有登陆 都会存在
    std::map<userid_t, IMUserPtr> users_id_;
    // 登陆用户 token -> user users_hash_ 存在的user uses_id_ 中必定存在
    std::map<std::string, IMUserPtr> users_hash_;

public:
    static IMUserManager *getInstance()
    {
        if (instance_ == nullptr)
        {
            instance_ = new IMUserManager();
        }
        return instance_;
    }

    void addUser(const IMUserPtr user);

    void removeUser(const IMUserPtr user);
    void removeUser(const userid_t &uid);
    void removeUser(const std::string &token);

    IMUserPtr FindUser(const userid_t &uid) const;
    IMUserPtr FindUser(const std::string &token);
};